﻿
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class WeiXinConfig : PageBase
    {


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.txtWeixXinType.Value = base.curParameter.bolWeiXinType ? "1" : "0";
                this.txtWeiXinVerified.Value = base.curParameter.bolWeiXinVerified ? "1" : "0";
                this.txtSignInPoint.Value = base.curParameter.intSignInPoint.ToString();
                this.txtWeiXinToken.Value = base.curParameter.strWeiXinToken;
                this.txtEncodingAESKey.Value = base.curParameter.strWeiXinEncodingAESKey;
                this.txtWeiXinShopName.Value = base.curParameter.strWeiXinShopName;
                this.txtWeiXinSalutatory.Value = base.curParameter.strWeiXinSalutatory;
                this.txtAppId.Value = base.curParameter.strWeiXinAppID;
                this.txtAppSecret.Value = base.curParameter.strWeiXinAppSecret;
                this.chkWeiXinSMSVcode.Checked = base.curParameter.bolWeiXinSMSVcode;
                this.spanUrl.InnerText = base.Request.Url.AbsoluteUri.Substring(0, base.Request.Url.AbsoluteUri.IndexOf(base.Request.Url.AbsolutePath)) + "/Service/WeiXinHandler.ashx";
                this.spanToken.InnerText = PubFunction.curParameter.strWeiXinToken;
                this.spanEncodingAESKey.InnerText = PubFunction.curParameter.strWeiXinEncodingAESKey;
            }
            if (base.Request["weixin"] != null)
            {
                if (base.Request["weixin"] != "0")
                {
                    this.SetState("disabled");
                }
            }
            else if (PubFunction.curParameter.istry != 1)
            {
                this.SetState("disabled");
            }
        }

        public void SetState(string disabled)
        {
            this.txtWeixXinType.Attributes.Add("disabled", disabled);
            this.txtWeiXinVerified.Attributes.Add("disabled", disabled);
            this.txtSignInPoint.Attributes.Add("disabled", disabled);
            this.txtWeiXinToken.Attributes.Add("disabled", disabled);
            this.txtEncodingAESKey.Attributes.Add("disabled", disabled);
            this.txtWeiXinShopName.Attributes.Add("disabled", disabled);
            this.txtWeiXinSalutatory.Attributes.Add("disabled", disabled);
            this.txtAppId.Attributes.Add("disabled", disabled);
            this.txtAppSecret.Attributes.Add("disabled", disabled);
            this.chkWeiXinSMSVcode.Attributes.Add("disabled", disabled);
            this.Step1Next.Attributes.Add("disabled", disabled);
            this.btnCreateRandomAESKey.Attributes.Add("disabled", disabled);
            this.btnCreateRandomToken.Attributes.Add("disabled", disabled);
            if (disabled != "")
            {
                this.lblMessage.Visible = true;
            }
        }
    }


